* Replication code for Aarøe, Petersen and Arceneaux (2017) US Sample 1 *

* This do file reproduces analyses related to the US Sample 1
* Use the following replication data set: "Replication Data Set US Sample 1"
** See the Online Appendix for details on question wording and survey flow

set more off

******************************************************************************************************
* recodings and reliability code reported here
******************************************************************************************************

******************************************************************************************************
*recodings and reliability codes for Test 1
******************************************************************************************************


*Creating scales for contamination disgust, core disgust and animal reminder disgust

* recoding of items for the contamination disgust, core disgust and animal reminder disgust scales
** Note: items 1, 6, and 10 must be reversed; run the code below ONLY ONCE.
gen monkey01 = 4 - q3_1
gen roach06 = 4 - q3_6
gen eye10 = 4 - q3_10

ta monkey01
ta roach06
ta eye10 

recode q3_2 (0=0) (1=1) (2=2) (3=3) (4=4), gen (hand02)
recode q3_3 (0=0) (1=1) (2=2) (3=3) (4=4), gen (throat03)
recode q3_4 (0=0) (1=1) (2=2) (3=3) (4=4), gen (toilet04)
recode q3_5 (0=0) (1=1) (2=2) (3=3) (4=4), gen (grave05)
recode q3_7 (0=0) (1=1) (2=2) (3=3) (4=4), gen (body07)
recode q3_8 (0=0) (1=1) (2=2) (3=3) (4=4), gen (vomit08)
recode q3_9 (0=0) (1=1) (2=2) (3=3) (4=4), gen (cook09)
recode q3_11 (0=0) (1=1) (2=2) (3=3) (4=4), gen (rat11)

recode q3_13 (0=0) (1=1) (2=2) (3=3) (4=4), gen (soup13) 
recode q3_14 (0=0) (1=1) (2=2) (3=3) (4=4), gen (hotel14)
recode q4_1 (0=0) (1=1) (2=2) (3=3) (4=4), gen (maggots15)

recode q4_3 (0=0) (1=1) (2=2) (3=3) (4=4), gen (urine17)
recode q4_4 (0=0) (1=1) (2=2) (3=3) (4=4), gen (soda18)
recode q4_5 (0=0) (1=1) (2=2) (3=3) (4=4), gen (cat19)
recode q4_6 (0=0) (1=1) (2=2) (3=3) (4=4), gen (icecrm20)
recode q4_7 (0=0) (1=1) (2=2) (3=3) (4=4), gen (intest21)
recode q4_8 (0=0) (1=1) (2=2) (3=3) (4=4), gen (underw22)
recode q4_9 (0=0) (1=1) (2=2) (3=3) (4=4), gen (chocl23)
recode q4_10 (0=0) (1=1) (2=2) (3=3) (4=4), gen (ashes24)
recode q4_11 (0=0) (1=1) (2=2) (3=3) (4=4), gen (milk25)
recode q4_12 (0=0) (1=1) (2=2) (3=3) (4=4), gen (condom26)
recode q4_13 (0=0) (1=1) (2=2) (3=3) (4=4), gen (worm27)
 
* creation of the core disgust scale 
egen core_av=rmean(monkey01 throat03 roach06 vomit08 rat11 soup13 maggots15 urine17 icecrm20 underw22 milk25 worm27)

* creation of the animal reminder disgust scale
egen anrem_av = rmean(hand02 grave05 body07 eye10 hotel14 cat19 intest21 ashes24)

* creation of the contamination disgust scale
egen contam_av = rmean (toilet04 cook09 soda18 chocl23 condom26)

* Creation of a contamination disgust scale without the item referencing sexual behavior (for Online Appendix A5.2)
egen contam_nosexual =rmean(toilet04 cook09 soda18 chocl23)
gen contam_nosexual01=(contam_nosexual/4)

* creation of the full DS-R scale
egen dsr_av = rmean (monkey01 hand02 throat03 toilet04 grave05 roach06 body07 vomit08 cook09 eye10 rat11 soup13 hotel14 maggots15 urine17 soda18 cat19 icecrm20 intest21 underw22 chocl23 ashes24 milk25 condom26 worm27)

*recoding the core disgust, animal reminder disgust, contamination disgust and the DS-R scales to range from 0 to 1
gen core_av01 =core_av/4
gen anrem_av01 =anrem_av/4
gen contam_av01 =contam_av/4
gen dsr_av01 =dsr_av/4

*Crohnbachs' alpha reliability coefficient for the core disgust scale (reported in Online Appendix A5.1)
alpha monkey01 throat03 roach06 vomit08 rat11 soup13 maggots15 urine17 icecrm20 underw22 milk25 worm27
 
* Crohnbachs' alpha reliability coefficient for the animal reminder disgust scale (reported in Online Appendix A5.1)
alpha hand02 grave05 body07 eye10 hotel14 cat19 intest21 ashes24

* Crohnbachs' alpha reliability coefficient for the contamination disgust scale (reported in the main text in "Materials and methods" in Test 1 and in Online Appendix A4.1.2)
alpha toilet04 cook09 soda18 chocl23 condom26

* mean and standard deviation of the contamination disgust scale (reported in Online Appendix A4.1.2)
sum contam_av01
 
* Crohnbachs' alpha reliability coefficient for the DSR-R scale (reported in Online Appendix A5.1)
alpha monkey01 hand02 throat03 toilet04 grave05 roach06 body07 vomit08 cook09 eye10 rat11 soup13 hotel14 maggots15 urine17 soda18 cat19 icecrm20 intest21 underw22 chocl23 ashes24 milk25 condom26 worm27
  
*creation of the scale measuring opposition to immigration (ranging from 0 to 1)
recode q12_1 q12_3 q12_5 (0=6) (1=5) (2=4) (3=3) (4=2) (5=1) (6=0), gen (q12_1r q12_3r q12_5r)
egen antiim1= rmean(q12_2 q12_4 q12_6 q12_1r q12_3r q12_5r)
gen antiim=antiim1/6

*Crohnbachs' alpha reliability coefficient for the scale measuring opposition to immigration (reported in the main text in "Materials and methods" in Test 1 and in Online Appendix A4.2)
alpha q12_2 q12_4 q12_6 q12_1r q12_3r q12_5r

* mean and standard deviation of the scale measuring opposition to immigration (reported in Online Appendix A4.2)  
sum antiim

* ideology ranging from 0 to 1, higher values more conservative
recode q1 (1=1) (2=2) (3=3) (4=4) (5=5) (6=.) (8=.) (9=.), gen (ideo1)
gen ideo = (ideo1-1)/4
ta ideo
label variable ideo "ideo higher values more conservative"

* mean and standard deviation of the ideology scale (reported in Online Appendix A4)
sum ideo

* ideology coded in three categories (for Table A9 in Online Appendix A5.4)
gen ideo3=ideo
recode ideo3 (0=0) (.25=0) (.5=1) (.75=2) (1=2)
ta ideo3
label define ideo3 0 "Liberals" 1 "Middle of the road" 2 "Conservatives
label values ideo3 ideo3

* age 
ta age

* income ranging from 0 to 1
recode income_v2 (97=.) (31=.), gen (income)
ta income
gen income01=(income-1)/15

* race 
gen nonwhite=1
replace nonwhite = 0 if race==1 
label define nonwhite 1 "nonwhite" 0 "Caucasian/white"
label values nonwhite nonwhite

*education ranging from 0 to 1
gen education01=(educ-1)/5
ta education01

*gender (1 = female)
gen female=gender
recode female (1=0) (2=1) 
label define female 1 "female" 0 "male"
 

******************************************************************************************************
*Additional recodings for Test 3
******************************************************************************************************

* Experimental treatment variable: Intention cues
gen exp=.
replace exp = 1 if q5a !=.
replace exp = 1 if q5d !=.
replace exp = 2 if q5b !=.
replace exp = 2 if q5e !=.
replace exp = 3 if q5c !=.
replace exp = 3 if q5f !=.
label define exp 1 "control" 2 "bad intentions" 3 "good intentions" 
label values exp exp

* Experimental treatment variable: Cues about the familiarity of the immigrant 
gen exprace=.
replace exprace = 1 if q5a !=.
replace exprace = 1 if q5b !=.
replace exprace = 1 if q5c !=.
replace exprace = 0 if q5d !=.
replace exprace = 0 if q5e !=.
replace exprace = 0 if q5f !=.
label define exprace 1 "Unfamiliar Middle Eastern" 0 "Familiar Eastern European"
label values exprace exprace

gen EastEurope=exprace
recode EastEurope (1=0) (0=1)
label define EastEurope 1 "Familiar Eastern European" 0 "Unfamiliar Middle Eastern"
label values EastEurope EastEurope

 * Creating of scale measuring opposition to entering immigrant (ranging from 0 to 1)
recode q5a q5b q5c q5d q5e q5f (0=6) (1=5) (2=4) (3=3) (4=2) (5=1) (6=0), gen (q5arc q5brc q5crc q5drc q5erc q5frc)
egen LiveHere=rmean ( q5arc q5brc q5crc q5drc q5erc q5frc)
ta LiveHere
egen NegLife=rmean( q7a_1 q7b_1)
ta NegLife
egen NegEcon=rmean (q7a_2 q7b_2)

egen imthreat=rmean(LiveHere NegLife NegEcon)
ta imthreat
gen imthreat01=imthreat/6

* reliability of the scale measuring opposition to entering immigrant (reported in "Research design and Measures" in Test 3 in the main text and in Online Appendix A9)
alpha LiveHere NegLife NegEcon

* mean and standard deviation of the scale measuring opposition to the entering immigrant (reported in Online Appendix A9)
sum imthreat01

******************************************************************************************************
* Sample characteristics (reported in the Online Appendix A3.1)
******************************************************************************************************

ta female
ta income
sum ideo
recode income_v2 (97=.)
ta income_v2
sum age

******************************************************************************************************
* Analyses
******************************************************************************************************

***********************************************************
*Results for Test 1
***********************************************************

* Results reported in the main text

* Test 1, Table 2, Model 1, main text
eststo: reg antiim contam_av01 female age education01 ideo income01 nonwhite
esttab, b(%5.2f) se(%5.2f), using part_2.rtf, replace onecell star(* 0.10 ** 0.02 *** 0.002) wide constant ar2
eststo clear

*Test 1 - footnote 6, main text and Online Appendix A5.4, Table A8, Model 1 - interactions between behavioral immune sensitivity and ideology
eststo: reg antiim c.contam_av01##c.ideo female age education01 income01 nonwhite, robust
esttab, b(%5.2f) se(%5.2f), using part_2.rtf, replace onecell star(* 0.10 ** 0.02 *** 0.002) wide constant ar2
eststo clear


* Results reported in the Online Appendix

* Test 1 - Online Appendix A4.1.4, Table A3, column 1 - bivariate correlations between measures of behavioral immune sensitivity and demographics (two-sided tests)
pwcorr contam_av01 education01 income01 female nonwhite age, sig obs

* Test 1 - Online Appendix A5.1, Table A5, Models 1-2, - correlation between contamination disgust and antiimmigration attitudes controling for other types of disgust
reg antiim contam_av01 dsr_av01, beta
reg antiim contam_av01 anrem_av01 core_av01, beta 

* Results reported in the Online Appendix A5.2 Supplemental analysis of robustness of the effect of contamination disgust in Table 2 in the main text excluding the item referencing sexual behavior
reg antiim contam_nosexual01 female age education01 ideo income

* Test 1 - Online Appendix A5.4, Table A7, Model 1 - zero-order correlation with ideology
pwcorr ideo contam_av01, sig obs

*Test 1 - footnote 6, main text and Online Appendix A5.4, Table A8, Model 1 - interactions between behavioral immune sensitivity and ideology
eststo: reg antiim c.contam_av01##c.ideo female age education01  nonwhite income01, robust
esttab, b(%5.2f) se(%5.2f), using part_2.rtf, replace onecell star(* 0.10 ** 0.02 *** 0.002) wide constant ar2
eststo clear

* Test 1 - Online Appendix A5.4, Table A9, first row - mean and standard deviation in behavioral immune sensitivity by ideology (3 categories)
bys ideo3: sum contam_av01

* Test 1 - Supplemetal analysis reported in text in Online Appendix A5.4 - conservatives report significantly higher behavioral immune sensitivity than liberals
reg contam_av01 i.ideo3


******************************************************************
* Results reported for Test 3
******************************************************************

* Results reported in the main text 

* Test 3 - manipulation check reported in the main text and in Online Appendix A10.1, Table A15 
eststo: reg imthreat01 i.exp i.EastEurope c.contam_av01 i.female c.age c.education01 c.ideo c.income01 i.nonwhite
esttab, b(%5.2f) se(%5.2f), using part_2.rtf, replace onecell star(* 0.10 ** 0.02 *** 0.002) wide constant ar2
eststo clear

* Test 3 - checking the exact p-value (w. more decimals) for the effect of familiar origin reported in the main text and in Online Appendix A10.1, Table A15
eststo: reg imthreat01 i.exp i.EastEurope c.contam_av01 i.female c.age c.education01 c.ideo c.income01 i.nonwhite
esttab, b(%5.2f) p(%5.4f), using part_2.rtf, replace  wide constant ar2
eststo clear

* Test 3 - Table 4, Models 1-2 in the main text
eststo: reg imthreat01 i.EastEurope##c.contam_av01  i.female c.age c.education01 c.ideo c.income01 i.nonwhite, robust 
eststo: reg imthreat01 i.exp##c.contam_av01 i.female c.age c.education01 c.ideo c.income01 i.nonwhite, robust    
esttab, b(%5.2f) se(%5.2f), using part_2.rtf, replace onecell star(* 0.10 ** 0.02 *** 0.002) wide constant ar2
eststo clear

* Test 3 - Figure 1, Panels A-D 
* Test 3 - Figure 1, Panel A, Marginal effect of disgust sensitivity by immigrant origin
* we have manually edited the lines for the cofidence intervals to be dashed and the color of the point estimate to be black, font size medium for labels
reg imthreat01 i.EastEurope##c.contam_av01  i.female c.age c.education01 c.ideo c.income01 i.nonwhite, robust
margins, dydx(contam_av01) at(EastEurope=(0 1)) level(90)
marginsplot,recast(scatter) ciopts(recast(rcap) graphregion(color(white)) lcolor(black)) xlabel(0 "Middle Eastern" 1 "Eastern European") yline(0) xscale(range(-0.5 1.5)) xtitle("") ytitle("Marginal effect of disgust sensitivity") yscale(range(-.1 (.1) .3)) ylabel(-.1(0.1).3) title("") scheme(s1mono) name(Int5, replace) 

* Test 3 - Figure 1, Panel C, Marginal effect of disgust sensitivity by intention cues 
*** we have manually edited the lines for the cofidence intervals to be dashed and the color of the point estimate to be black, font size medium for labels
reg imthreat01 i.exp##c.contam_av01  i.female c.age c.education01 c.ideo c.income01 i.nonwhite, robust
margins, dydx(contam_av01) at(exp=(1 2 3)) level(90)
marginsplot,recast(scatter) ciopts(recast(rcap) graphregion(color(white)) lcolor(black)) xlabel(1 "No intentions cues" 2 "Bad intentions" 3 "Good intentions") yline(0) xscale(range(0.5 3.5)) xtitle("") ytitle("Marginal effect of disgust sensitivity") yscale(range(-.1 (.1) .3)) ylabel(-.1(0.1).3) title("") scheme(s1mono) name(Int3, replace) 

* Test 3 - Figure 1, Panel B, Predicted opposition to entering immigrant by disgust sensitivity and immigrant origin
reg imthreat01 i.EastEurope##c.contam_av01  i.female c.age c.education01 c.ideo c.income01 i.nonwhite, robust
margins, at(contam_av01=(0 (.1) 1) EastEurope=(0 1)) level(90)
marginsplot,recast(line) ciopts(recast(rline) lp(dash) graphregion(color(white))) xtitle("Disgust sensitivity") ytitle("Opposition to entering immigrant") yscale(range(.15 (.1) .85)) ylabel(.15(0.1).85) title("") scheme(s1mono) name(Int4, replace)

*Test 3 - Figure 1, Panel D, Predicted opposition to entering immigrant by disgust sensitivity and intention cues
reg imthreat01 i.exp##c.contam_av01  i.female c.age c.education01 c.ideo c.income01 i.nonwhite, robust
margins, at(contam_av01=(0 (.1) 1) exp=(1 2 3))  level (90)
marginsplot,recast(line) ciopts(recast(rline) lp(dash) graphregion(color(white))) xtitle("Disgust sensitivity") ytitle("Opposition to entering immigrant") yscale(range(.15 (.1) .85)) ylabel(.15(0.1).85) title("") scheme(s1mono) name(Int4, replace)

* Test 3, footnote 8 in the main text and Online Appendix A10.2, Table A16 - the unique effect of contamination disgust (no similar effect with education and income)
eststo: reg imthreat01 i.EastEurope##c.contam_av01  i.female c.age c.education01 c.ideo c.income01 i.nonwhite, robust 
eststo: reg imthreat01 i.exp##c.contam_av01 i.female c.age c.education01 c.ideo c.income01 i.nonwhite, robust  
eststo: reg imthreat01 i.EastEurope##c.education01 c.contam_av01 i.female c.age c.ideo c.income01 i.nonwhite, robust 
eststo: reg imthreat01 i.exp##c.education01 c.contam_av01 i.female c.age  c.ideo c.income01 i.nonwhite, robust  
eststo: reg imthreat01 i.EastEurope##c.income01 c.contam_av01 i.female c.age c.education01 c.ideo  i.nonwhite, robust 
eststo: reg imthreat01 i.exp##c.income01 c.contam_av01 i.female c.age c.education01 c.ideo i.nonwhite, robust  
esttab, b(%5.2f) se(%5.2f), using part_2.rtf, replace onecell star(* 0.10 ** 0.02 *** 0.002) wide constant ar2
eststo clear







